<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组扩容</title>

    <script>
        //方法一 修改数组长度
        var array1 = [424, 214, 212];
        console.log(array1); //(3) [424, 214, 212]
        //扩容5个
        array1.length = array1.length + 5;
        console.log(array1); //(8) [424, 214, 212, empty × 5]
        //方法二 直接追加
        var array2 = [214, 21, 4, 154];
        console.log(array2); //(4) [214, 21, 4, 154]
        array2[4] = 2141;
        console.log(array2); //(5) [214, 21, 4, 154, 2141]
    </script>

</head>

<body>

</body>

</html>